package com.example.administrator.myjdlc.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.RadioGroup;

import com.example.administrator.myjdlc.R;
import com.example.administrator.myjdlc.fragment.AccountFragement;
import com.example.administrator.myjdlc.fragment.FinancesFragement;
import com.example.administrator.myjdlc.fragment.ServiceFragement;
import com.example.administrator.myjdlc.ui.MyRadioButton;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/4/24.
 */

public class MainActivity extends FragmentActivity {
    @Bind(R.id.fl_main)
    FrameLayout mainFrameLayout;
    @Bind(R.id.tag1)
    MyRadioButton tag1;
    @Bind(R.id.tag2)
    MyRadioButton tag2;
    @Bind(R.id.tag3)
    MyRadioButton tag3;
    @Bind(R.id.rdg_bottom)
    RadioGroup rdgBottom;
    private FragmentTransaction fragmentTransaction;
    private FragmentManager supportFragmentManager;
    private FinancesFragement fragment;
    private AccountFragement fragment1;
    private ServiceFragement fragment2;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 设置自定义的标题栏
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        fragment = new FinancesFragement();
        fragment1 = new AccountFragement();
        fragment2 = new ServiceFragement();
        supportFragmentManager = getSupportFragmentManager();

        supportFragmentManager.beginTransaction().replace(R.id.fl_main, new FinancesFragement()).commit();


    }

   /* @Override
    public void initBaseData() {
        FragmentManager fragmentManager = getFragmentManager();
        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.replace(R.id.fl_main, new FinancesFragement());
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void initListener() {

    }*/

    @OnClick({R.id.tag1, R.id.tag2, R.id.tag3})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tag1:

                supportFragmentManager.beginTransaction().replace(R.id.fl_main, fragment).commit();
                break;
            case R.id.tag2:
                supportFragmentManager.beginTransaction().replace(R.id.fl_main, fragment1).commit();
                break;
            case R.id.tag3:
                supportFragmentManager.beginTransaction().replace(R.id.fl_main, fragment2).commit();
                break;
        }
    }
}
